package main

import (
	"fmt"
	_ "fmt"
	"log"
	_ "log"
	"net/http"
	_ "net/http"
	"test-go/web_test/config"
)

func handleReq(w http.ResponseWriter, r *http.Request) {
	s := "你好 geo web"
	fmt.Fprintf(w, "%s", s)
	log.Printf("%s", s)
}

func main() {
	fmt.Println("Start to server")
	http.Handle("/", &ThisHandle{})
	http.HandleFunc("/hi", handleReq)
	config.InitMysql()

	var row []map[string]interface{}

	config.DB.Raw("select * from t1").Scan(&row)
	fmt.Println(row)

	if err := http.ListenAndServe(":8080", nil); err != nil {
		log.Fatal("Listen server", err)
	}
}

type ThisHandle struct {
}

func (handle *ThisHandle) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("ThisHandle ServeHTTP"))
}
